const express = require('express')
const fs = require('fs')

const app = express()

app.use(haha)

app.get('/admin', function(req, res) {
    res.send('管理员')
})

app.listen(3000)

function haha(req, res, next) {
    const filePath = req.originalUrl
    fs.readFile('./public/' + filePath, (err, data) => {
        if (err) {
            // 文件不存在
            next()
            return
        }
        res.send(data.toString())
    })
}